package com.example.bean;

import com.example.bean.Product;
import com.example.bean.Student;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class SpringTest {
    public static void main(String[] args) {
        // 1.加载Spring配置文件
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

        Student student=(Student) context.getBean("student");
        System.out.println("从Spring容器获取的学生信息：");
        System.out.println(student);

        Product product=(Product) context.getBean("product");
        System.out.println("从Spring容器获取的产品信息：");
        System.out.println(product);
    }
}
